﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Framework.Verifications;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Web;

namespace Pixysoft.Weblications.Sango.Command.general
{
    partial class SangoGeneralHandler
    {
        public general_login general_login(string loginname)
        {
            general_login response = ReflectionManager.CreatePojo<general_login>();
            response.Succeed = false;

            string usercode = SangoManager.GetUsercode();

            if (!Verification.Verifies(loginname).IsNotNullOrEmpty().Result())
            {
                response.Status = general_login_const.UNKNOWN;
                return response;
            }

            loginname = loginname.Trim().ToUpper();
            Entities.Usr_Profile profile = UsrProfileDao.tryGetProfileByLoginName(loginname);
            if (profile == null)
            {
                response.Status = general_login_const.NOUSER;
                return response;
            }

            //内存注册用户

            SessionHelper.Instance.AddSession(StringHelper.session_profile, profile.Usercode);

            //通知好友上线

            //结算银矿、农田


            response.Succeed = true;
            return response;
        }
    }

    public interface general_login : ISangoResponse
    {
    }

    public class general_login_const
    {
        public const int UNKNOWN = 0;
        public const int NOUSER = 1;
    }
}
